<template>
  <div class='aftersale-detail first-box'>
    <Form :formData="formData" :formParam="formParam"></Form>
    <Buttons v-show="formParam.state=='待确认'" class="margintop80" :buttonData="buttonData" ></Buttons>
  </div>
</template>
<script>
import Form from '../../../common/form'
import Buttons from '../../../common/button.vue'
export default {
  components: {Form,Buttons},
  name: "",
  data() {
    return {
      formData:[
        {
          title:{
            show:false,
          },
          children:[
            {type:"input",placeholder:"无",label:"姓名",key:"name",readonly:true},
            {type:"input",placeholder:"无",label:"联系电话",key:"phone",readonly:true},
            {type:"input",placeholder:"无",label:"车型号",key:"carModel",readonly:true},
            {type:"input",placeholder:"无",label:"车牌号",key:"carNum",readonly:true},
            {type:"input",placeholder:"无",label:"预约类型",key:"bookType",readonly:true},
            {type:"input",placeholder:"无",label:"预约时间段",key:"bookDate",readonly:true},
            {type:"input",placeholder:"无",label:"提交时间",key:"takeDate",readonly:true},
            {type:"input",placeholder:"无",label:"状态",key:"state",readonly:true}
          ],
        }
      ],
      formParam:{
        state:"待确认",//0待确认，1已确认
      },
      buttonData:[
        {
          label:"确认",
          click:this.save,
        },
      ]
    };
  },
  methods: {
    save(){
      var params={
        id:this.formParam.id
      }
      _g.apiPost("afterBooking/confirm.do",params).then(res=>{
        _g.toMessage(res)
        if(!res.error){
          this.$set(this.formParam,"state","已确认")
          setTimeout(()=>{
            this.$router.go(-1)
          },600)
        }
      })
    }
  },
  created() {
    var params={
      id:sessionStorage.getItem("detailId")
    }
    _g.apiPost("afterBooking/getUserInfo.do",params).then(res=>{
      res.data.state="待确认"
      
      this.$set(this,"formParam",res.data)
    })
  }
};
</script>
<style lang="scss" scoped>
.aftersale-detail {
  .margintop80{
    padding: 80px 30px 0;
  }
}
</style>